//获取应用实例
var app = getApp()
var util = require('../../utils/util.js');

Page({
  data: {
    imgurl: '',
    list: [],
    oldList: [],// 原始数据，未经筛选
    listType: 'list',
    total: 0,
    pageNum: 0,
    goodsGroupId: 0, // 产品分组
    sort: 'createTime',// 排序
    order: 'desc',
    goodGroupName: '',
    isShow: false,//显示内容
    showNoneRefresh: false,//刷新无更多
    showNoData: false, //无数据
    // 规格弹出层
    showLoadIngGg: true,
    goods: '', // 产品
    ggList: '', // 产品规格集合
    ggListArr: '', // 筛选规格
    ggValue0: '',
    ggValue1: '',
    ggValue2: '',
    isChoice: false,
    vaArr: [],
    goodsGg: {}, // 选中规格
    chPrice: '',
    chStock: '',
    goodNum: '1',
    margin:3,
    width:168,
    inputShowed: false,
    inputVal: "",
    paegType: "",
    gpid: ""
  },
  onLoad: function (options) {
    try {
      var res = wx.getSystemInfoSync()
      var w=res.windowWidth-12;
      var margin = parseInt(w*0.01)
      var width = (w-margin*4)/2
      this.setData({ margin: margin, width: width})
    } catch (e) {
      // Do something when catch error
    }
    //调用应用实例的方法获取全局数据
    var that = this
    if (app.shopConfig) {
      var shopConfig = app.shopConfig
      that.setData({ listType: shopConfig.goodsStyle })
    }
    that.setData({ imgurl: app.imageUrl})
  },
  onReady: function () {
    // 页面渲染完成
  },
  onShow: function () {
    // 页面显示
    this.setData({ showNoneRefresh: false, showNoData:false })
  },
  onHide: function () {
    // 页面隐藏
  },
  onUnload: function () {
    // 页面关闭
  },
  clearInput: function () {
    this.setData({
      inputVal: ""
    });
  },
  inputTyping: function (e) {
    this.setData({
      inputVal: e.detail.value
    });
    
  },
  search: function () {
    app.goodsListFilter = this.data.inputVal
    wx.redirectTo({
      url: '../goods/goodsList'
    })
  }
})
